﻿Imports System.Collections.ObjectModel
Imports OMANE.Common.Model.Interfaces
Imports PTIC_GestionBDD
Imports PTIC_Util

Public Class TablesTravailFactory
    Implements IReferentielTablesTravailTraitements

    Public Sub New(ByVal InfosTables As ReadOnlyCollection(Of IInfoTableReferentiel),
                   ByVal ListeTraitements As ListeTraitementsBase(Of String))
        m_InfosTables = InfosTables
        m_ListeTraitements = ListeTraitements
    End Sub

#Region "Liste des tables disponibles dans le référentiel"
    Private m_InfosTables As ReadOnlyCollection(Of IInfoTableReferentiel)
    Protected ReadOnly Property InfosTables As ReadOnlyCollection(Of IInfoTableReferentiel)
        Get
            Return m_InfosTables
        End Get
    End Property
    Public ReadOnly Property NomsTablesDisponibles As System.Collections.Generic.List(Of String) Implements IReferentielTablesTravailTraitements.NomsDisponibles
        Get
            Return (From InfoTable As IInfoTableReferentiel In m_InfosTables
                   Select InfoTable.NomTable).ToList
        End Get
    End Property
#End Region

#Region "Récupération du traitement pointant sur une table du référentiel"
    'Private m_Traitements As IDictionary(Of IInfoTableReferentiel, ITraitement)
    Private m_ListeTraitements As ListeTraitementsBase(Of String)
    Public ReadOnly Property Traitements(ByVal InfoTable As IInfoTableReferentiel) As tableBDD Implements IReferentielTablesTravailTraitements.Item
        Get
            If Not m_ListeTraitements.ContainsKey(InfoTable.NomTable) Then

                Dim table_BDD As tableBDD = New TableBDD_SAS(InfoTable.NomTable, csteLibSASreferentiel)
                m_ListeTraitements.Add(InfoTable.NomTable, table_BDD)
                table_BDD.FichierBDD.NomComplet = csteEmplacementReferentiel & InfoTable.NomFichier

            End If
            Return m_ListeTraitements(InfoTable.NomTable)
        End Get
    End Property
#End Region

End Class
